@extends('pc_admin.app')

@section('content')
<link rel="stylesheet" href="/css/pc-system/attendance-left.css">
<link rel="stylesheet" href="/css/pc-system/main-list.css?v=2019052901">
<div class="mian-container">
    <div class="container-section main-list">
        <div class="f-left left-section">
            <div class="title-list top-list">
                <h3 class="h3-title"><a href="{{url('/sysadmin/group/index')}}"><i class="icon iconfont icon-icon-test"></i>部门管理</a></h3>
            </div>
            @foreach($tongxunlu as $t)
                <div class="section-list">
                    <div class="title-list">
                        <h3 class="h3-title">
                            @if($t['group_name'] != '我的同事')<img class="list-user" src="/img/list-user1.png" style="vertical-align: middle; width: 18px;  height: 18px;">@endif
                                {{trim($t['group_name'])}}
                        </h3>
                        <span class="num-span"></span>
                    </div>
                    <ul>
                        @foreach($t['member'] as $m)
                            @if($m['is_leader'] == 1)
                                <li onclick="window.location.href='/sysadmin/user/index?userid={{$m['id']}}'">
                                    <img class="sec-img" src="{{userlogo($m['id'])}}">
                                    <span class="sec-name" >{{$m['qw_name']}}</span>
                                    @if($m['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                    @foreach($m['role'] as $mr)
                                        <span class="circle-span @if($mr==10) span-score @elseif($mr==11) span-exam @elseif($mr==12) span-reward @endif">{{$rolearray[$mr]}}</span>
                                    @endforeach
                                </li>
                            @endif
                        @endforeach
                        @foreach($t['member'] as $m)
                            @if($m['is_leader'] != 1)
                                <li onclick="window.location.href='/sysadmin/user/index?userid={{$m['id']}}'">
                                    <img class="sec-img" src="{{userlogo($m['id'])}}">
                                    <span class="sec-name" >{{$m['qw_name']}}</span>
                                    @if($m['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                    @foreach($m['role'] as $mr)
                                        <span class="circle-span @if($mr==10) span-score @elseif($mr==11) span-exam @elseif($mr==12) span-reward @endif">{{$rolearray[$mr]}}</span>
                                    @endforeach
                                </li>
                            @endif
                        @endforeach
                    </ul>
                    @if(isset($t['child']))
                        @foreach($t['child'] as $c)
                            <div class="second-list">
                                <div class="title-list">
                                    <h3 class="h3-title">
                                        <img class="list-user" src="/img/list-user1.png" style="vertical-align: middle; width: 18px;  height: 18px;">
                                         {{$c['group_name']}}
                                    </h3>
                                    <span class="num-span"></span>
                                </div>
                                <ul>
                                    @foreach($c['member'] as $cm)
                                        @if($cm['is_leader'] == 1)
                                            <li>
                                                <img class="sec-img" src="{{userlogo($cm['id'])}}">
                                                <span class="sec-name" onclick="window.location.href='/sysadmin/user/index?userid={{$cm['id']}}'">{{$cm['qw_name']}}</span>
                                                @if($cm['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                                @foreach($cm['role'] as $cmr)
                                                    <span class="circle-span @if($cmr==10) span-score @elseif($cmr==11) span-exam @elseif($cmr==12) span-reward @endif">{{$rolearray[$cmr]}}</span>
                                                @endforeach
                                            </li>
                                        @endif
                                    @endforeach
                                    @foreach($c['member'] as $cm)
                                        @if($cm['is_leader'] != 1)
                                            <li>
                                                <img class="sec-img" src="{{userlogo($cm['id'])}}">
                                                <span class="sec-name" onclick="window.location.href='/sysadmin/user/index?userid={{$cm['id']}}'">{{$cm['qw_name']}}</span>
                                                @if($cm['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                                @foreach($cm['role'] as $cmr)
                                                    <span class="circle-span @if($cmr==10) span-score @elseif($cmr==11) span-exam @elseif($cmr==12) span-reward @endif">{{$rolearray[$cmr]}}</span>
                                                @endforeach
                                            </li>
                                        @endif
                                    @endforeach
                                </ul>
                                @foreach($c['child'] as $cc)
                                    <div class="third-list">
                                        <div class="title-list">
                                            <h3 class="h3-title">
                                                <img class="list-user" src="/img/list-user1.png" style="vertical-align: middle; width: 18px;  height: 18px;">
                                                 {{$cc['group_name']}}
                                            </h3>
                                            <span class="num-span"></span>
                                        </div>
                                        <ul>
                                            @foreach($cc['member'] as $ccm)
                                                @if($ccm['is_leader'] == 1)
                                                    <li>
                                                        <img class="sec-img" src="{{userlogo($ccm['id'])}}">
                                                        <span class="sec-name" onclick="window.location.href='/sysadmin/user/index?userid={{$ccm['id']}}'">{{$ccm['qw_name']}}</span>
                                                        @if($ccm['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                                        @foreach($ccm['role'] as $ccmr)
                                                            <span class="circle-span @if($ccmr==10) span-score @elseif($ccmr==11) span-exam @elseif($ccmr==12) span-reward @endif">{{$rolearray[$ccmr]}}</span>
                                                        @endforeach
                                                    </li>
                                                @endif
                                            @endforeach
                                            @foreach($cc['member'] as $ccm)
                                                @if($ccm['is_leader'] != 1)
                                                    <li>
                                                        <img class="sec-img" src="{{userlogo($ccm['id'])}}">
                                                        <span class="sec-name" onclick="window.location.href='/sysadmin/user/index?userid={{$ccm['id']}}'">{{$ccm['qw_name']}}</span>
                                                        @if($ccm['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                                        @foreach($ccm['role'] as $ccmr)
                                                            <span class="circle-span @if($ccmr==10) span-score @elseif($ccmr==11) span-exam @elseif($ccmr==12) span-reward @endif">{{$rolearray[$ccmr]}}</span>
                                                        @endforeach
                                                    </li>
                                                @endif
                                            @endforeach
                                        </ul>
                                    </div>
                                @endforeach
                            </div>
                        @endforeach
                    @endif
                </div>
            @endforeach
        </div>
        <div class="right-section center-list">
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $('.h3-title').parent().next('ul').css('display','none');
        $('.center-list').css('min-height',$('.left-section').height());
        $('.num-span').each(function(){
            $(this).text($(this).parent().next('ul').children().length);
        });
        $('.h3-title').each(function () {
            var that= this
            if($(that).text().trim()=='我的同事'){
                $(that).parent().addClass('active');
                $('.center-list').html($(that).parent().next('ul').html());
            }
        });
        $('.icon-qizi').prev('.sec-name').css('color','#F46555')
        $('.title-list').click(function () {
            $(this).parents().find('.title-list').removeClass('active');
            $(this).addClass('active');
            //$(this).find('.list-user').attr('src','/img/list-user2.png');
            $('.center-list').html($(this).next('ul').html());
        })
    })
    var ugid = {{$active}};
    $('#'+ugid).addClass('active');
</script>
@endsection